import { QueryClient, useQuery } from "@tanstack/react-query";
import { ThemeService } from "@/shared/api/api.theme";

export function useGetAllThemes() {
    const queryClient = new QueryClient
    const { isLoading, error, data, refetch, isSuccess } =
        useQuery(
            {
                queryKey: ['query-getAllThemes'],
                queryFn: ThemeService.getAll,
            }, queryClient
        )

    const errorMessage = error ? "Load disciplines failed" : undefined;

    return {
        themes: data,
        errorMessage,
        refetch,
        isLoading,
        isSuccess
    };
}